//
//  AbstractMessage.m
//  gongwei-ios
//
//  Created by gongwei-mac on 2020/1/21.
//  Copyright © 2020 gongwei-mac. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Message.h"
#import "MessageResponseType.h"
#import "MessageType.h"

@implementation Message
-(long)getCreateTime {
    return self.createTime;
}

-(MessageType)getContentType {
    return MT_SERVICE_REQUEST;
}

-(BOOL)isResponseRequired {
    MessageResponseType responseType = [self getResponseType];
    return !responseType && responseType != MRT_NONE;
}

-(BOOL)isMultiResponse {
    MessageResponseType responseType = [self getResponseType];
    return !responseType && responseType != MRT_MULTIPLE;
}

-(MessageResponseType)getResponseType {
    MessageType contentType = [self getContentType];
       
    MessageResponseType responseType;

    if(contentType) {
       switch (contentType) {
           case MT_PLAIN_MESSAGE:
               responseType = MRT_AT_MOST_ONE;
               break;
           default:
               responseType = MRT_NONE;
       }
    } else {
       responseType = MRT_NONE;
    }
    return responseType;
}

-(void)fillFromDictionary:(NSData *)data {
    
}

-(NSMutableDictionary *)parseToDictionary: (BOOL) withTag {
    NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
   if (self.createTime) {
       [dictionary setObject: [NSNumber numberWithLong:self.createTime] forKey:@"createTime"];
   }
    return dictionary;
}

@end
